package com.hx01.modules.manager.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hx01.common.annotation.SysLog;
import com.hx01.modules.manager.entity.StoreInfoEntity;
import com.hx01.modules.manager.service.StoreInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 店铺信息表(StoreInfo)表控制层
 *
 * @author makejava
 * @since 2020-12-25 22:59:05
 */
@RestController
@RequestMapping("storeInfo")
@Api(tags = "店铺信息表")
public class StoreInfoController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private StoreInfoService storeInfoService;

    /**
     * 分页查询所有数据
     *
     * @param page      分页对象
     * @param storeInfo 查询实体
     * @return 所有数据
     */
    @GetMapping("/list")
    @ApiOperation("分页查询所有数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页大小", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "size", value = "每页大小", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "desc", value = "倒序排序字段与asc二选一，排序字段需要驼峰转换成下划线", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "asc", value = "正序排序字段与desc二选一, 排序字段需要驼峰转换成下划线", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "id", value = "数据ID", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "leaderName", value = "商户负责人姓名", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "leaderMobile", value = "商户负责人手机号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeName", value = "店铺名称", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeArea", value = "店铺地址 精确到省市区", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeAddress", value = "店铺详细地址 精确到门牌号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "payMethod", value = "结账模式 1 先吃后付 2 先付后吃", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeNotice", value = "本店公告", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeDesc", value = "门店介绍", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "serviceInfo", value = "服务信息", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeLogo", value = "店铺logo", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeFeature", value = "门店特色", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sorting", value = "排序值", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "revision", value = "乐观锁", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "status", value = "数据状态 0禁用 1正常", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "createUserId", value = "创建人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "createTime", value = "创建时间", required = false, dataTypeClass = Date.class),
            @ApiImplicitParam(name = "updateUserId", value = "更新人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "updateTime", value = "更新时间", required = false, dataTypeClass = Date.class),
    })
    public R selectAll(Page<StoreInfoEntity> page, StoreInfoEntity storeInfo) {
        return success(this.storeInfoService.page(page, new QueryWrapper<>(storeInfo)));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation("通过主键查询单条数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据主键id", required = true, dataTypeClass = String.class)
    })
    public R selectOne(@PathVariable Serializable id) {
        return success(this.storeInfoService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param storeInfo 实体对象
     * @return 新增结果
     */
    @SysLog("新增数据")
    @PostMapping("/save")
    @ApiOperation("新增数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据ID", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "leaderName", value = "商户负责人姓名", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "leaderMobile", value = "商户负责人手机号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeName", value = "店铺名称", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeArea", value = "店铺地址 精确到省市区", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeAddress", value = "店铺详细地址 精确到门牌号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "payMethod", value = "结账模式 1 先吃后付 2 先付后吃", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeNotice", value = "本店公告", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeDesc", value = "门店介绍", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "serviceInfo", value = "服务信息", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeLogo", value = "店铺logo", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeFeature", value = "门店特色", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sorting", value = "排序值", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "revision", value = "乐观锁", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "status", value = "数据状态 0禁用 1正常", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "createUserId", value = "创建人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "createTime", value = "创建时间", required = false, dataTypeClass = Date.class),
            @ApiImplicitParam(name = "updateUserId", value = "更新人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "updateTime", value = "更新时间", required = false, dataTypeClass = Date.class),
    })
    public R insert(@RequestBody StoreInfoEntity storeInfo) {
        return success(this.storeInfoService.save(storeInfo));
    }

    /**
     * 修改数据
     *
     * @param storeInfo 实体对象
     * @return 修改结果
     */
    @SysLog("修改数据")
    @PostMapping("/update")
    @ApiOperation("修改数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据ID", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "leaderName", value = "商户负责人姓名", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "leaderMobile", value = "商户负责人手机号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeName", value = "店铺名称", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeArea", value = "店铺地址 精确到省市区", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeAddress", value = "店铺详细地址 精确到门牌号", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "payMethod", value = "结账模式 1 先吃后付 2 先付后吃", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeNotice", value = "本店公告", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeDesc", value = "门店介绍", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "serviceInfo", value = "服务信息", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeLogo", value = "店铺logo", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "storeFeature", value = "门店特色", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sorting", value = "排序值", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "revision", value = "乐观锁", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "status", value = "数据状态 0禁用 1正常", required = false, dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "createUserId", value = "创建人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "createTime", value = "创建时间", required = false, dataTypeClass = Date.class),
            @ApiImplicitParam(name = "updateUserId", value = "更新人", required = false, dataTypeClass = String.class),
            @ApiImplicitParam(name = "updateTime", value = "更新时间", required = false, dataTypeClass = Date.class),
    })
    public R update(@RequestBody StoreInfoEntity storeInfo) {
        return success(this.storeInfoService.updateById(storeInfo));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @SysLog("删除数据")
    @PostMapping("/delete")
    @ApiOperation("删除数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "idList", value = "主键数据集合", required = true, dataTypeClass = List.class)
    })
    public R delete(@RequestParam("idList") List<Long> idList) {
        return success(this.storeInfoService.removeByIds(idList));
    }
}